unit F_SeleccionReporte;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, JvExStdCtrls, JvRadioButton, Buttons, ExtCtrls;

type
  TForm_Seleccion_Reporte = class(TForm)
    Panel_Inferior: TPanel;
    BB_Cancelar: TBitBtn;
    BB_Seleccionar: TBitBtn;
    Panel_Central: TPanel;
    Panel_R_Documentos: TPanel;
    GB_R_Documentos: TGroupBox;
    JvRadioButton1: TJvRadioButton;
    JvRadioButton2: TJvRadioButton;
    JvRadioButton3: TJvRadioButton;
    procedure BB_SeleccionarClick(Sender: TObject);
    procedure BB_CancelarClick(Sender: TObject);
    procedure JvRadioButton1KeyPress(Sender: TObject; var Key: Char);
  private
    { Private declarations }
    function GetActiveCheckBox(Panel:TWinControl):integer;

    procedure CreateReporteDocumento;
    procedure CreateReporteCopias;
    procedure CreateReporteMateria;
  public
    { Public declarations }
  end;

implementation

uses F_Reporte_Copias_No_Impresas, F_RCopiasPorDocumento, F_RMateria;

{$R *.dfm}

function TForm_Seleccion_Reporte.GetActiveCheckBox(Panel:TWinControl):integer;
var
  i:integer;
begin
  for i:=0 to Panel.ControlCount-1 do
    if (Panel.Controls[i] is TJvRadioButton) then
      begin
      if (TJvRadioButton(Panel.Controls[i]).Checked) then
        Result:= TJvRadioButton(Panel.Controls[i]).Tag;
      end
    else
      Result:= GetActiveCheckBox(TWinControl(Panel.Controls[i]));
end;

procedure TForm_Seleccion_Reporte.BB_SeleccionarClick(Sender: TObject);
begin
  case GetActiveCheckBox(Panel_Central) of
    1: CreateReporteDocumento;
    2: CreateReporteCopias;
    3: CreateReporteMateria;
  else
    Caption := Caption;
  end;
end;

procedure TForm_Seleccion_Reporte.CreateReporteDocumento;
begin
  with TF_CopiasPorDocumento.Create(TComponent(Self), 1) do
    begin
      ShowModal;
      Free;
    end;
end;

procedure TForm_Seleccion_Reporte.CreateReporteMateria;
begin
  with TF_RMaterias.Create(TComponent(Self), 1) do
    begin
      ShowModal;
      Free;
    end;
end;

procedure TForm_Seleccion_Reporte.CreateReporteCopias;
begin
  with TF_Reporte_NoImprimible.Create(TComponent(Self)) do
    begin
      ShowModal;
      Free;
    end;
end;

procedure TForm_Seleccion_Reporte.BB_CancelarClick(Sender: TObject);
begin
  Close;
end;

procedure TForm_Seleccion_Reporte.JvRadioButton1KeyPress(Sender: TObject; var Key: Char);
begin
  if (Key = #13) then
    BB_SeleccionarClick(nil);
end;

end.
